home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Interactive Reference Guide / C-C++ Interactive Reference Guide.iso / c_ref / csource1 / mpegplay / util32.c < prev    next >
C/C++ Source or Header  |  1994-02-13  |  2KB  |  77 lines

  1. #include <stdio.h>
  2. /* @@@ AK, Fake up XWindows for OS/2 */
  3. #if defined(OS2)
  4. #include "xstub.h"
  5. #else
  6. #include <X11/Xlib.h>
  7. #include <X11/Xutil.h>
  8. #endif
  9. #include "video.h"
  10. #include "proto.h"
  11.  
  12. /*
  13.  * Return a pointer to a full color bit visual on the dpy
  14.  */
  15. Visual *
  16. FindFullColorVisual (dpy, depth)
  17.     Display *dpy;
  18.     int *depth;
  19. {
  20.   XVisualInfo vinfo;
  21.   XVisualInfo *vinfo_ret;
  22.   int numitems, maxdepth;
  23.   
  24.   vinfo.class = TrueColor;
  25.   
  26.   vinfo_ret = XGetVisualInfo(dpy, VisualClassMask, &vinfo, &numitems);
  27.   
  28.   if (numitems == 0) return NULL;
  29.  
  30.   maxdepth = 0;
  31.   while(numitems > 0) {
  32.     if (vinfo_ret[numitems-1].depth > maxdepth) {
  33.       maxdepth = vinfo_ret[numitems-1 ].depth;
  34.     }
  35.     numitems--;
  36.   }
  37.   XFree(vinfo_ret);
  38.  
  39.   if (maxdepth < 24) return NULL;
  40.  
  41.   if (XMatchVisualInfo(dpy, DefaultScreen(dpy), maxdepth, 
  42.                TrueColor, &vinfo)) {
  43.     *depth = maxdepth;
  44.     return vinfo.visual;
  45.   }
  46.   
  47.   return NULL;
  48. }
  49.  
  50. Window
  51. CreateFullColorWindow (dpy, x, y, w, h)
  52.     Display *dpy;
  53.     int x, y, w, h;
  54. {
  55.     int depth;
  56.     Visual *visual;
  57.     XSetWindowAttributes xswa;
  58.     unsigned int mask;
  59.     unsigned int class;
  60.     int screen;
  61.  
  62.     screen = XDefaultScreen(dpy);
  63.     class = InputOutput;    /* Could be InputOnly */
  64.     visual = FindFullColorVisual (dpy, &depth);
  65.     if (visual == NULL) {
  66.     return 0;
  67.     }
  68.     mask = CWBackPixel | CWColormap | CWBorderPixel;
  69.     xswa.colormap = XCreateColormap(dpy, XRootWindow(dpy, screen),
  70.             visual, AllocNone);
  71.     xswa.background_pixel = BlackPixel(dpy, DefaultScreen(dpy));
  72.     xswa.border_pixel = WhitePixel(dpy, DefaultScreen(dpy));
  73.  
  74.     return XCreateWindow(dpy, RootWindow(dpy, screen), x, y, w, h,
  75.     1, depth, class, visual, mask, &xswa);
  76. }
  77.